#include "CCondition.h"

CCondition::CCondition()
{
	//pthread_mutex_init(&m_Mutex, NULL);
  pthread_cond_init(&m_Cond, NULL);
}

CCondition::~CCondition()
{
  //pthread_mutex_destroy(&m_Mutex);
  pthread_cond_destroy(&m_Cond);
}

int CCondition::Wait(CThreadMutex *objMutex)
{
  return pthread_cond_wait(&m_Cond, objMutex->GetThdMutex());
}

int CCondition::TimeWait(CThreadMutex *objMutex, int iSec)
{
	struct timespec tsp;
	tsp.tv_sec = iSec;
	tsp.tv_nsec = 0;
  return  pthread_cond_timedwait(&m_Cond, objMutex->GetThdMutex(), &tsp);
}

int CCondition::Signal()
{
  return pthread_cond_signal(&m_Cond);
}
